package com.hfjyz.examination.command;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Set;

import org.springframework.beans.BeanUtils;
import org.springframework.util.AutoPopulatingList;

import com.hfjyz.examination.domain.ExamDetail;
import com.hfjyz.examination.domain.PaperDetail;
import com.hfjyz.examination.domain.Question;
import com.hfjyz.examination.domain.QuestionCategory;
import com.hfjyz.examination.domain.QuestionOptions;

public class QuestionEditCommand implements Serializable {
	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 3951051794692787065L;
	private Question question;
	@SuppressWarnings("unchecked")
	private List<QuestionOptions> questionOptionses = new AutoPopulatingList(
			QuestionOptions.class);
	private QuestionCategory category = new QuestionCategory();

	@SuppressWarnings("unchecked")
	private List<String> keys = new AutoPopulatingList(
			String.class);

	public QuestionEditCommand() {
		this.setQuestion(new Question());
	}

	public QuestionEditCommand(Question question) {
		this.setQuestion(question);
		BeanUtils.copyProperties(category, question.getQuestionCategory());
		this.questionOptionses.addAll(question.getQuestionOptionses());
	}

	/**
	 * @return the question
	 */
	public Question getQuestion() {
		return question;
	}

	/**
	 * @param question
	 *            the question to set
	 */
	public void setQuestion(Question question) {
		this.question = question;
	}

	/**
	 * @return
	 * @see com.hfjyz.examination.domain.Question#getId()
	 */
	public Long getId() {
		return question.getId();
	}

	/**
	 * @param id
	 * @see com.hfjyz.examination.domain.Question#setId(java.lang.Long)
	 */
	public void setId(Long id) {
		question.setId(id);
	}

	/**
	 * @return
	 * @see com.hfjyz.examination.domain.Question#getVersion()
	 */
	public int getVersion() {
		return question.getVersion();
	}

	/**
	 * @param version
	 * @see com.hfjyz.examination.domain.Question#setVersion(int)
	 */
	public void setVersion(int version) {
		question.setVersion(version);
	}

//	/**
//	 * @return
//	 * @see com.hfjyz.examination.domain.Question#getQuestionCategory()
//	 */
//	public QuestionCategory getQuestionCategory() {
//		QuestionCategory questionCategory = question.getQuestionCategory();
//		if (questionCategory == null) {
//			questionCategory = new QuestionCategory();
//			question.setQuestionCategory(questionCategory);
//		}
//		return questionCategory;
//	}
//
//	/**
//	 * @param questionCategory
//	 * @see com.hfjyz.examination.domain.Question#setQuestionCategory(com.hfjyz.examination.domain.QuestionCategory)
//	 */
//	public void setQuestionCategory(QuestionCategory questionCategory) {
//		question.setQuestionCategory(questionCategory);
//	}

	/**
	 * @return
	 * @see com.hfjyz.examination.domain.Question#getQtype()
	 */
	public Integer getQtype() {
		return question.getQtype();
	}

	/**
	 * @param qtype
	 * @see com.hfjyz.examination.domain.Question#setQtype(java.lang.Integer)
	 */
	public void setQtype(Integer qtype) {
		question.setQtype(qtype);
	}

	/**
	 * @return
	 * @see com.hfjyz.examination.domain.Question#getQlevel()
	 */
	public Integer getQlevel() {
		return question.getQlevel();
	}

	/**
	 * @param qlevel
	 * @see com.hfjyz.examination.domain.Question#setQlevel(java.lang.Integer)
	 */
	public void setQlevel(Integer qlevel) {
		question.setQlevel(qlevel);
	}

	/**
	 * @return
	 * @see com.hfjyz.examination.domain.Question#getQfrom()
	 */
	public Integer getQfrom() {
		return question.getQfrom();
	}

	/**
	 * @param qfrom
	 * @see com.hfjyz.examination.domain.Question#setQfrom(java.lang.Integer)
	 */
	public void setQfrom(Integer qfrom) {
		question.setQfrom(qfrom);
	}

	/**
	 * @return
	 * @see com.hfjyz.examination.domain.Question#getStatus()
	 */
	public String getStatus() {
		return question.getStatus();
	}

	/**
	 * @param status
	 * @see com.hfjyz.examination.domain.Question#setStatus(java.lang.String)
	 */
	public void setStatus(String status) {
		question.setStatus(status);
	}

	/**
	 * @return
	 * @see com.hfjyz.examination.domain.Question#getContent()
	 */
	public String getContent() {
		return question.getContent();
	}

	/**
	 * @param content
	 * @see com.hfjyz.examination.domain.Question#setContent(java.lang.String)
	 */
	public void setContent(String content) {
		question.setContent(content);
	}

	/**
	 * @return
	 * @see com.hfjyz.examination.domain.Question#getPostdate()
	 */
	public Date getPostdate() {
		return question.getPostdate();
	}

	/**
	 * @param postdate
	 * @see com.hfjyz.examination.domain.Question#setPostdate(java.util.Date)
	 */
	public void setPostdate(Date postdate) {
		question.setPostdate(postdate);
	}

	/**
	 * @return
	 * @see com.hfjyz.examination.domain.Question#getQkey()
	 */
	public String getQkey() {
		return question.getQkey();
	}

	/**
	 * @param qkey
	 * @see com.hfjyz.examination.domain.Question#setQkey(java.lang.String)
	 */
	public void setQkey(String qkey) {
		question.setQkey(qkey);
	}

	/**
	 * @return
	 * @see com.hfjyz.examination.domain.Question#getKeydesc()
	 */
	public String getKeydesc() {
		return question.getKeydesc();
	}

	/**
	 * @param keydesc
	 * @see com.hfjyz.examination.domain.Question#setKeydesc(java.lang.String)
	 */
	public void setKeydesc(String keydesc) {
		question.setKeydesc(keydesc);
	}

	/**
	 * @return
	 * @see com.hfjyz.examination.domain.Question#getCdate()
	 */
	public Date getCdate() {
		return question.getCdate();
	}

	/**
	 * @param cdate
	 * @see com.hfjyz.examination.domain.Question#setCdate(java.util.Date)
	 */
	public void setCdate(Date cdate) {
		question.setCdate(cdate);
	}

	/**
	 * @return
	 * @see com.hfjyz.examination.domain.Question#getPaperDetails()
	 */
	public Set<PaperDetail> getPaperDetails() {
		return question.getPaperDetails();
	}

	/**
	 * @param paperDetails
	 * @see com.hfjyz.examination.domain.Question#setPaperDetails(java.util.Set)
	 */
	public void setPaperDetails(Set<PaperDetail> paperDetails) {
		question.setPaperDetails(paperDetails);
	}

	/**
	 * @return
	 * @see com.hfjyz.examination.domain.Question#getQuestionOptionses()
	 */
	public List<QuestionOptions> getQuestionOptionses() {
		return questionOptionses;
	}

	/**
	 * @param questionOptionses
	 * @see com.hfjyz.examination.domain.Question#setQuestionOptionses(java.util.Set)
	 */
	public void setQuestionOptionses(List<QuestionOptions> questionOptionses) {
		this.questionOptionses.clear();
		this.questionOptionses.addAll(questionOptionses);
	}

	/**
	 * @return
	 * @see com.hfjyz.examination.domain.Question#getExamDetails()
	 */
	public Set<ExamDetail> getExamDetails() {
		return question.getExamDetails();
	}

	/**
	 * @param examDetails
	 * @see com.hfjyz.examination.domain.Question#setExamDetails(java.util.Set)
	 */
	public void setExamDetails(Set<ExamDetail> examDetails) {
		question.setExamDetails(examDetails);
	}

	/**
	 * @return the category
	 */
	public QuestionCategory getCategory() {
		return category;
	}

	/**
	 * @param category
	 *            the category to set
	 */
	public void setCategory(QuestionCategory category) {
		this.category = category;
	}

	/**
	 * @return the keys
	 */
	public List<String> getKeys() {
		return keys;
	}

	/**
	 * @param keys the keys to set
	 */
	public void setKeys(List<String> keys) {
		this.keys = keys;
	}

}
